package cn.liufuwen.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;

import cn.liufuwen.domain.Goods;
import cn.liufuwen.entity.GoodsDTO;
import cn.liufuwen.mapper.GoodsMapper;
import cn.liufuwen.service.GoodsService;
import lombok.extern.java.Log;
@Log
//注册为 Dubbo 服务
@Service(version = "${demo.service.version}")  
public class GoodsServiceImpl implements GoodsService {
	@Autowired
    private GoodsMapper goodsMapper;
	@Override
	public List<GoodsDTO> listgoods() {
		List<GoodsDTO> listGoodsDTO = new ArrayList<GoodsDTO>();
		List<Goods> listGoods = goodsMapper.selectAll(); 
		log.info("商品列表，总数"+listGoods.size());
		for(Goods goods:listGoods){
			GoodsDTO goodsDTO = new GoodsDTO();
			goodsDTO.setId(goods.getId());
			goodsDTO.setGoodsName(goods.getGoodsName());
			goodsDTO.setGoodsPrice(goods.getGoodsPrice());
			goodsDTO.setGoodsStock(goods.getGoodsStock());
			listGoodsDTO.add(goodsDTO);
		}
		return listGoodsDTO;
	}

	@Override
	public int savegoods(GoodsDTO goodsDTO) { //商品入库
		
		return 0;
	}

	@Override
	public int removegoods(GoodsDTO goodsDTO) { //商品出库
		
		return 0;
	}	
	

}
